Navigation

More:





Impressum

related work

Next: license

Of course this is the original Ruby implementation just works. Go Ruby! http://haml-lang.com/

alternative PHP implementations (attempts)

Summary: If there had been a working library I would not have spend days on writing this. So I can't seriously recommend any of those.

Don't miss Wikipedia's page about Haml

phphaml

http://phphaml.sourceforge.net/

flaws rev 90:

phamlp

http://code.google.com/p/phamlp/
https://github.com/MarcWeber/phamlp

See my statement in the README. The parser will never be compliant without a rewrite. The author seems to be gone away ? No replies or updates for a long time.

Fammel

https://github.com/dxw/Fammel

The idea was to use a proper Parser lexer and grammar. Current status: broken which the author admitted. To make it work maybe a lot of more work has to be done. So they assigned higher priorities to other projects meanwhile...

Probbaly fixing it is not that hard: You could approximate PHP expressions the way its done in this library by rewriting this recursive regex in the grammar:

// (?R) matches to most outer regexp recursively
// That's something Ruby can't do (yet?)
// You can't just parse until you hit a ","
// because contents can be  %tag = substr(2,4,8)
// so the substr will be matched by "anything else", the (...) will be
// matched by the ", separated func args"

// keys are documentation only
$items = array(
  '" str' => '"([^"\\]+|[\\].)*"',
  "' str" => ''([^'\\]+|[\\].)*'',
  ', separated func args' =>  '(((?R)(,(?R))*))',
  'recursion in ()' => '((?R))', // this catches nested ( 2 + (4 + ) ) ..
  // '{(?R)}
  ' anything else but terminal' => "[^'"(){},n$s]+"
);
$regex ='('. implode('|',$items).')+';

phaml

http://phaml.sourceforge.net So if you don't want to pay for HAML-TO-PHP this could be an option - however not for production use.

kohaml

kohaml quote from README: "This module is old and outdated and does not yet work for Kohana V3. Instead take a look at a better implementation by Fred Wu here - https://github.com/fredwu/kohana-phamlp". phamlp see above.

Link missing? Contact support

Next: license